#include "Dialog.h"
#include "ui_Dialog.h"

Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{
    ui->setupUi(this);
    settings = new QSettings("Polytech", "LangageAndSettings");
    ui->langageComboBox->addItem("fr");
    ui->langageComboBox->addItem("en");
    connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(saveSettings()));
    this->loadSettings();
}

Dialog::~Dialog()
{
    delete ui;
    delete settings;
}

void Dialog::loadSettings()
{
    ui->lineEdit->setText(settings->value("lineEdit").toString());
    ui->langageComboBox->setCurrentIndex(settings->value("langage").toInt());
}

void Dialog::saveSettings()
{
    settings->setValue("lineEdit", ui->lineEdit->text());
    settings->setValue("langage", ui->langageComboBox->currentIndex());
}
